<!--
 * @Description: 
 * @version: 
 * @Author: 尹鹏孝
 * @Date: 2022-01-10 09:01:29
 * @LastEditors: 尹鹏孝
 * @LastEditTime: 2022-01-10 09:17:37
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>两两交换指针的节点</title>
</head>

<body>
    <script>
        /*  给定一个链表，两两交换其中相邻的节点，并返回交换后的链表。
     
         你不能只是单纯的改变节点内部的值，而是需要实际的进行节点交换。 */
        // 虚拟头结点
        var switchingNode = function (head) {
            let ret = new ListNode(0, head), temp = ret;
            while (temp.next && temp.next.next) {
                let cur = temp.next.next, pre = temp.next;
                pre.next = cur.next; cur.next = pre; temp.next = cur; temp = pre;
            }
            return ret.next;
        }

    </script>

</body>

</html>